# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>

pkgname=python-beautifulsoup4
_pkgname="${pkgname#python-}"
pkgver=4.12.2
pkgrel=1
pkgdesc='A Python HTML/XML parser designed for quick turnaround projects like screen-scraping'
arch=('any')
url='https://www.crummy.com/software/BeautifulSoup/'
license=('MIT')
depends=(
  'python'
  'python-soupsieve'
)
optdepends=(
  'python-chardet: to autodetect character encodings'
  'python-lxml: alternative HTML parser'
  'python-html5lib: alternative HTML parser'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-hatchling'
)
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://www.crummy.com/software/BeautifulSoup/bs4/download/${pkgver%.*}/$_pkgname-$pkgver.tar.gz")
sha512sums=('1dbb620f675bb319ef050ece0f343e80359bdc59cd8b8de19b1851aa5bca1081a7e953e3221ad97142198c17f67384c05b0406af24a123d71398f209fb89db97')
b2sums=('94412a87dcffeb14655417eb61a784c8933aea79c81721ebf30114d55fd3e0f58850e0cfed354d3573d1bf18b556f3d83474b64a2a8d88f503c5125d5931321d')

build() {
  cd "$_pkgname-$pkgver"

  python -m build --wheel --no-isolation
}

check() {
  cd "$_pkgname-$pkgver"

  pytest -v
}

package() {
  cd "$_pkgname-$pkgver"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
